<?php
$url = '?md=' . MvcReg::$_moduleName . '&cl=' . MvcReg::$_controllerName . '&at=' . str_replace('add', '', MvcReg::$_actionName) . 'update';

$id = $name = $permission = $rank = $discription = '';
if (!empty($rsp_list)) {
    $row = $rsp_list;
    $id = $row["id"];

}
?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <?php include_once MvcReg::$_moduleName . '/views/layout/head.php'; ?>
</head>
<body>
<?php include_once MvcReg::$_moduleName . '/views/layout/woody-prompt.php'; ?>
<?php include_once MvcReg::$_moduleName . '/views/layout/header.php'; ?>
<div id="main">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-2">
                <?php include_once MvcReg::$_moduleName . '/views/layout/left_menu.php'; ?>
            </div>
            <div class="col-md-10">
                <div class="right-content">
                    <h3>
                        <ol class="breadcrumb"><li><a href="?md=manage&cl=front&at=question_list"><i class="fa fa-dashboard"></i><?php echo $menu["breadcrumb_current"]?></a><li class="active"><?php echo ((!empty($id) && ($id > 0)) > 0 ? '%{EDIT}%' : '%{ADD}%')?></li></li></ol>
                    </h3>

                    <br>
                    <form class="form-horizontal" action="<?php echo $url?>" method="post" autocomplete="off">
                        <div class="form-group">
                            <label for="cname" class="col-md-2 control-label">
                                <i>*</i>标题：
                            </label>
                            <div class="col-md-6">
                                <input type="text" name ="title" class="form-control " placeholder="标题" value="<?php echo $rsp_list['title']; ?>" required/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="title" class="col-md-2 control-label">
                                <i>*</i>内容：
                            </label>
                            <div class="col-md-6">
                                <textarea name="text" class="form-control " id="" cols="100" rows="10" required><?php echo $rsp_list['text']; ?></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="stacode" class="col-md-2 control-label">
                            </label>
                            <div class="col-md-4">
                                <?php if (empty($IsHidden)){?>
                                    <button type="submit" class="btn btn-success">保存</button>
                                <?php }else {?>
                                    <button type="button" class="btn btn-primary" onclick="window.location.href='?md=manage&cl=front&at=question_list&page=<?php echo $page?>'">回上一级</button>
                                <?php }?>
                            </div>
                            <span class="col-md-6"></span>
                        </div>
                        <input type="hidden" id="page" name="page" value="<?php echo $page?>"/>
                        <input type="hidden" id="id" name="id" value="<?php echo $rsp_list['id']?>"/>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<?php include_once MvcReg::$_moduleName . '/views/layout/footer.php'; ?>

<script>
    $(function () {

        $('.checkSub').click(function () {
            //alert($(this).attr('class').substr(9));
            var c = $(this).attr('class').substr(9);
            var len = $('.col-sm-4').find('.' + c).length;
            var len_check = $('.col-sm-4').find('.' + c + ":checked").length;
            if (len == len_check) {
                //alert("等于："+len);
                $('.col-sm-4').find('.' + c + "0").prop("checked", "checked");
            } else {
                //alert("NO"+len);
                $('.col-sm-4').find('.' + c + "0").removeAttr('checked');
            }
        });

        $('.checkMain').each(function () {
            $(this).click(function () {
                if ($(this).is(':checked')) {

                    $(this).parent('li').find('.checkSub').prop("checked", "checked");

                } else {
                    $(this).parent('li').find('.checkSub').removeAttr('checked')
                }
            });
        });

        $('#allgroup').bind("click", function(){
            //alert(1);
            if ($(this).is(':checked')) {
                $('.checkMain').prop("checked", "checked");
                $('.checkSub').prop("checked", "checked");
            } else {
                $('.checkMain').prop("checked", false);
                $('.checkSub').prop("checked", false);
            }
        });
    });
</script>
</html>